cordova.define("mamp-plugin-cpdaily", function(require, exports, module) {

var exec = require('cordova/exec');

var cpdaily = function(){};
               
/*
 desc:显示登录页
 @param exceptFlag：异常状态标记(cookie失效/被踢下线等等)。为空或false时表示无异常，仅仅是未登录。为true表示为异常状态。默认为空
 */
cpdaily.prototype.showLoginView = function(exceptFlag) {
    exec(null,null,"cpdaily","showLoginView",[exceptFlag]);
};

/*
 desc:显示或隐藏tabbar
 @param show  true-显示；false-隐藏
 */
cpdaily.prototype.showOrHideTabbar = function(show) {
    exec(null,null,"cpdaily","showOrHideTabbar",[show]);
};

/*
 desc:显示设置页
 */
cpdaily.prototype.showSettingView = function() {
    exec(null,null,"cpdaily","showSettingView",[]);
};
               
/*
 desc:获取首页上部显示的收藏的4个应用
 */
cpdaily.prototype.mainAppListChange = function(callback) {
    exec(callback,null,"cpdaily","mainAppListChange",[]);
};

/*
 desc:打开应用市场
 */
cpdaily.prototype.openMarketList = function(callback) {
    exec(callback,null,"cpdaily","openMarketList",[]);
};

/*
 desc:获取租户ID
 */
cpdaily.prototype.getTenantID = function(callback) {
    exec(callback,null,"cpdaily","getTenantID",[]);
};

/*
 desc:获取租户信息
 */
cpdaily.prototype.getTenantInfo = function(callback) {
    exec(callback,null,"cpdaily","getTenantInfo",[]);
};

/*
desc:关闭当前页面，展示首页内容
*/
cpdaily.prototype.showMain = function() {
    exec(null,null,"cpdaily","showMain",[]);
};

/*
desc:设置状态栏颜色
*/
cpdaily.prototype.setStatusBarColor = function(color,statusBarTextColorFlag) {
    exec(null,null,"cpdaily","setStatusBarColor",[{"color":color,"statusBarTextColorFlag":statusBarTextColorFlag}]);
};

/*
desc:监听我的应用是否有改变
*/
cpdaily.prototype.onMineAppChanged = function(callback) {
    exec(callback,null,"cpdaily","onMineAppChanged",[]);
};

/*
desc:发起私聊
*/
cpdaily.prototype.startIMChat = function(userId, name) {
    exec(null,null,"cpdaily","startIMChat",[userId, name]);
};
/*
* 诸葛IO事件记录
* @para type      事件类型
* @para parameter 事件参数(键值对json数据)
*/
cpdaily.prototype.zhugeioTrack = function(type, parameter) {
    exec(null, null, "cpdaily", "zhugeioTrack", [type, parameter]);
};
/**
 * 向服务地址上传指定的文件
 * @param {array} filePathList 本地文件列表
 * @param {function} successCallback  (OPTIONAL)上传成功的回调
 * @param {function} errorCallback    (OPTIONAL)上传失败的回调
 */
cpdaily.prototype.uploadToOSS = function(filePathList, successCallback, errorCallback) {
    exec(successCallback, errorCallback, "cpdaily", "uploadToOSS", [filePathList]);
};
/**
 * desc:打开应用
 * */
cpdaily.prototype.openApp = function(appInfo) {
    exec(null,null,"cpdaily","openApp",[appInfo]);
};

/*
关注，取消关注用户
@para userId  今日校园用户唯一id
@para focus  是否关注的标识，true or false
*/
cpdaily.prototype.toggleFocus = function(userId,focus,callback){
    exec(callback, null, "cpdaily", "toggleFocus", [{"userId":userId,"focus":focus}]);
};

/*
获取某些用户的基本信息
idsNos:用户的学号，是一个数组类型
*/
cpdaily.prototype.getUserBasicInfos = function(idsNos,callback){
    exec(callback, null, "cpdaily", "getUserBasicInfos", [idsNos]);
};

/*
打开个人主页
@para userId  今日校园用户唯一id
*/
cpdaily.prototype.openHomePage = function(userId){
    exec(null, null, "cpdaily", "openHomePage", [userId]);
};

/*
打开人员列表页面
@para idList  今日校园用户唯一id
*/
cpdaily.prototype.openUsersPage = function(idList){
    exec(null, null, "cpdaily", "openUsersPage", [idList]);
};

/*
点击切换推荐和最新
@parm recommend 或者 new
*/
cpdaily.prototype.clickHomeTab = function(item){
    exec(null, null, "cpdaily", "clickHomeTab", [item]);
};

/*
首页顶部tab切换
@param callback切换后的回调函数，会返回圈子id
*/
cpdaily.prototype.onMainNavTabChanged = function(callback){
    exec(callback, null, "cpdaily", "onMainNavTabChanged", []);
};

/*
 desc:打开一个webview，它是从顶部开始布局（导航栏的下面）
 url:可以传递http地址或者mamp://hybrid/xxx/xxx.html?a=1&b=2
 options:可选参数
 {
  title:'',
  navBarStatus:'show',
  navBarBgColor:'08a1cd',
  statusBarTintColor:'000000'
 }
 */
cpdaily.prototype.openFullWebView = function(url,options) {
    exec(null,null,"cpdaily","openFullWebView",[url,options == null ? {}:options]);
};

/*
设置导航栏透明或者非透明
*/
cpdaily.prototype.toggleNavTransparent = function(transparent){
    exec(null, null, "cpdaily", "toggleNavTransparent", [transparent]);
};
/*
 打开评论页
 @para url 打开地址
 @para freshId 新鲜事ID
*/
cpdaily.prototype.openCommentView = function(url, freshId){
    exec(null, null, "cpdaily", "openCommentView", [url, freshId]);
};

/*
获取一组图片的宽高等详情
imgUrlList:图片地址列表
callback:回调，键值对数组：{[width:100, height:100, mime:"png"],[...]}
         如果有任何错误情况，塞空字典
*/
cpdaily.prototype.getImagesInfo = function(imgUrlList,callback){
    exec(callback, null, "cpdaily", "getImagesInfo", [imgUrlList]);
};

/*
格式化图片为base64字符串
imgUrl:图片地址
callback:回调，base64字符串
         如果有任何错误情况，塞空字符串
*/
cpdaily.prototype.formatImageToBase64 = function(imgUrl,callback){
    exec(callback, null, "cpdaily", "formatImageToBase64", [imgUrl]);
};

/*
解析出网页图片和标题
url:源网页地址
callback:回调，返回字典,key为"img"、"title"
*/
cpdaily.prototype.parseInfoFromHTML = function(url,callback){
    exec(callback, null, "cpdaily", "parseInfoFromHTML", [url]);
};

/*
 * 发布新鲜事
 * @param obj 发布新鲜事
 * @param callback:success(UUID) 添加成功 error(失败描述)
 */
cpdaily.prototype.publishFresh = function(obj, callback){
    exec(callback, null, "cpdaily", "publishFresh", [obj]);
};

/*
 * 检查是否存在发布新鲜事
 * @param callback: 发布新鲜事对象列表json
 */
cpdaily.prototype.checkPublishFresh = function(callback){
    exec(callback, null, "cpdaily", "checkPublishFresh", []);
};
/*
  发布成功的通知事件
  @param cicleId: 当前圈子ID
*/
cpdaily.prototype.onPublishFreshListener = function(cicleId, callback){
    exec(callback, null, "cpdaily", "onPublishFreshListener", [cicleId]);
};

/*
往今日校园发出一个通知
name:通知名称
params:json对象
*/
cpdaily.prototype.postNotification = function(name,params){
    exec(null, null, "cpdaily", "postNotification", [name,params]);
};
/*
显示用户引导遮罩页
params:字典类型参数，key为类型(0-首页全部应用，1-首页发布按钮，2-个人资料页)；value为对应的目标点坐标(字典，key为x,y,w,h,type)
*/
cpdaily.prototype.showUserGuide = function(params){
    exec(null, null, "cpdaily", "showUserGuide", [params]);
};

/*
获取登录用户个人资料接口,优化从缓存中拿，没有缓存时直接从网络取，callback中直接返回用户信息
*/
cpdaily.prototype.getUserInfo = function(callback){
    exec(callback, null, "cpdaily", "getUserInfo", []);
};

/*
获取首页圈子列表，直接返回一个圈子列表
*/
cpdaily.prototype.getCircleList = function(callback){
    exec(callback, null, "cpdaily", "getCircleList", []);
};
/*
显示组织单位选取器
callback:回调，返回选择的组织单位的id和单位名称字典:{"collegeCode":collegeCode,"name":name}
*/
cpdaily.prototype.showOrgSelector = function(callback){
    exec(callback, null, "cpdaily", "showOrgSelector", []);
};
/*
评论新鲜事或者评论回复
info对象{
    isCommentReply:true,//是否是评论回复,否则是评论新鲜事
    id:XXX,//新鲜事或者评论的id
    placeHolder:XXX //可以指定“回复XXX”
    followRect:{x:100,y:100,width:200,height:30}
}
callback:回调，会返回{id:xxxx}
*/
cpdaily.prototype.startComment = function(info,callback){
    exec(callback, null, "cpdaily", "startComment", [info]);
};

/*
打开编辑照片墙页面
array:当前已有的照片地址列表
callback:回调
*/
cpdaily.prototype.openPhotoWall = function(array,callback){
    exec(callback, null, "cpdaily", "openPhotoWall", [array]);
};

/*
重新发送新鲜事
taskId 新鲜事任务id
*/
cpdaily.prototype.retryFreshSend = function(taskId){
    exec(null, null, "cpdaily", "retryFreshSend", [taskId]);
};

/*
取消发送新鲜事
taskId 新鲜事任务id
*/
cpdaily.prototype.cancelFreshSend = function(taskId){
    exec(null, null, "cpdaily", "cancelFreshSend", [taskId]);
};

/*
打开个人详情页
@para sId 学工号
*/
cpdaily.prototype.openPersonalHome = function(sId){
    exec(null, null, "cpdaily", "openPersonalHome", [sId]);
};

module.exports = new cpdaily();
});